package org.cfg;

import com.sojoys.artifact.build.data.base.BaseCfg;
import java.util.List;
import com.sojoys.artifact.tools.ToolMap;
import com.sojoys.artifact.tools.ToolCopy;
import com.sojoys.artifact.factory.bytebuff.IByteBuff;
import java.util.Map;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.ArrayUtils;
import com.sojoys.artifact.tools.SK_String;
import com.xiaoleilu.hutool.util.StrUtil;
import com.sojoys.artifact.constant.DataModelKeyEnum;
/**
 * 灵装组合
 */
public class EquipmentCombinationCfg extends BaseCfg<EquipmentCombinationCfg> {

	/**
	 * 数据库表名称
	 */
	public static final String TABLE_NAME = "equipment_combination";
	/**
	 * 完整类名称
	 */
	public static final String CLASS_NAME = "org.cfg.EquipmentCombinationCfg"; 
	/**
	 * 字段个数
	 */
	public static final int COLUMN_COUNT= 4;
	/**
	 * 数据库源字段注释
	 */
	public static final String[] SOURCE_COLUMN_REMARKS = new String[]{"","组合类型","组合需要质点","组合技能",};
	/**
	 * 数据库源字段名字
	 */
	public static final String[] SOURCE_COLUMN_NAMES = new String[]{"id","type","needParticle","skill",};
	/**
	 * 拼音字段名字
	 */
	public static final String[] PINGYING_COLUMN_NAMES = new String[]{"id","type","needParticle","skill",};
	/**
	 * HashCode字段名字
	 */
	public static final Integer[] HASHCODE_COLUMN_NAMES = new Integer[]{3355,3575610,-1560582852,109496913,};
	/**
	 * 字段基本类型
	 */
	public static final String[] COLUMN_BASICTYPES = new String[]{"int","int","int[]","int[]",};
	/**
	 * 字段引用类型
	 */
	public static final Class[] COLUMN_CLASSTYPES = new Class[]{Integer.class,Integer.class,int[].class,int[].class,};
	
	/**
	 * id
	 */
	private int id;
	
	/**
	 * 组合类型
	 */
	private int type;
	
	/**
	 * 组合需要质点
	 */
	private int[] needParticle;
	
	/**
	 * 组合技能
	 */
	private int[] skill;
	
	
	
	public static EquipmentCombinationCfg builder() {
		EquipmentCombinationCfg equipmentCombinationCfg = new EquipmentCombinationCfg();
		return equipmentCombinationCfg;
	}
	
	/**
	 * id
	 */
	public int getId() {
		return id;
	}
	
	/**
	 * 组合类型
	 */
	public int getType() {
		return type;
	}
	
	/**
	 * 组合需要质点
	 */
	public int[] getNeedParticle() {
		return needParticle;
	}
	
	/**
	 * 组合技能
	 */
	public int[] getSkill() {
		return skill;
	}
	
	
	protected Object[] getColumnNames(DataModelKeyEnum e){
		switch (e) {
		case SOURCE:
			return SOURCE_COLUMN_NAMES;
		case PINGYING:
			return PINGYING_COLUMN_NAMES;
		case HASHCODE:
			return HASHCODE_COLUMN_NAMES;
		case REMARKS:
			return SOURCE_COLUMN_REMARKS;
		default:
			return PINGYING_COLUMN_NAMES;
		}
	}
	
	protected String[] getBasicTypes(){
		return COLUMN_BASICTYPES;
	}
	
	protected Class[] getClassTypes(){
		return COLUMN_CLASSTYPES;
	}
	
	protected Object[] getColumeValues(){
		Object[] values = new Object[COLUMN_COUNT];
        values[0] = this.id;
        values[1] = this.type;
        values[2] = this.needParticle;
        values[3] = this.skill;
        return values;
	}
	
	protected EquipmentCombinationCfg createColumeValues(Object[] vals) {
		this.id = (int)vals[0];
		this.type = (int)vals[1];
		this.needParticle = (int[])vals[2];
		this.skill = (int[])vals[3];
		return this;
	}
	
	protected Map<Object, Object> toMap(Object[] keys,Map<Object, Object> map){
        map.put(keys[0], this.id);
        map.put(keys[1], this.type);
        map.put(keys[2], this.needParticle);
        map.put(keys[3], this.skill);
        return map;
    }
    
    protected EquipmentCombinationCfg createForMap(Object[] keys,Map map){
   		this.id = (int)map.get(keys[0]);
   		this.type = (int)map.get(keys[1]);
   		this.needParticle = (int[])map.get(keys[2]);
   		this.skill = (int[])map.get(keys[3]);
        return this;
    }
	
	
	protected JSONObject toJSONObject(Object[] keys,JSONObject obj){
        obj.put(keys[0], this.id);
        obj.put(keys[1], this.type);
        obj.put(keys[2], this.needParticle);
        obj.put(keys[3], this.skill);
        return obj;
    }
    
    protected EquipmentCombinationCfg createForJSONObject(Object[] keys,JSONObject obj){
	    this.id = obj.getIntValue(keys[0]);
	    this.type = obj.getIntValue(keys[1]);
		this.needParticle = obj.getObject(keys[2],int[].class);
		this.skill = obj.getObject(keys[3],int[].class);
        return this;
    }
    
    protected void writeBytes(IByteBuff byteBuf){
	    byteBuf.writeInt(this.id);
	    byteBuf.writeInt(this.type);
	    byteBuf.writeObject(this.needParticle);
	    byteBuf.writeObject(this.skill);
    }
	
	protected EquipmentCombinationCfg readBytes(IByteBuff byteBuf){
	    this.id = byteBuf.readInt(null);
	    this.type = byteBuf.readInt(null);
	    this.needParticle = byteBuf.readIntArray(null);
	    this.skill = byteBuf.readIntArray(null);
	    return this;
	}
	
	public EquipmentCombinationCfg deepCopy(){
		EquipmentCombinationCfg equipmentCombinationCfg = null;
		try {
			equipmentCombinationCfg = (EquipmentCombinationCfg) super.clone();
		    equipmentCombinationCfg.needParticle = ToolCopy.copyObject(this.needParticle);
		    equipmentCombinationCfg.skill = ToolCopy.copyObject(this.skill);
			return equipmentCombinationCfg;
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		return equipmentCombinationCfg;
	}
//自定义内容起始位置
//自定义内容结束位置
}
